<template>
  <div class="data-statistics">
    <div class="list">
      <div class="item" v-for="(item, index) in dataStatisticsList" :key="index" @click="
        $router.push({
          path: '/order-log',
          query: { apResult: item.value },
        })
        ">
        <img :src="item.icon" alt="" />
        <div class="text">
          <div class="t1">{{ item.label }}</div>
          <div class="t2">{{ item.number }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import { replace, loginOutUser } from "@/utils";
import { mapGetters } from "vuex";
import apiService from "@/api/apiService";
// import storage from "store";
// import appConfig from "@/config/appConfig";
import dataSta01 from "@/assets/images/data_sta_03.png";
import dataSta02 from "@/assets/images/data_sta_05.png";
import dataSta03 from "@/assets/images/data_sta_08.png";
import dataSta04 from "@/assets/images/data_sta_11.png";
export default {
  data() {
    return {
      dataStatisticsList: [
        {
          label: this.$t("等待中"),
          number: 0,
          icon: dataSta01,
          value: 0,
        },
        {
          label: this.$t("进行中"),
          number: 0,
          icon: dataSta03,
          value: 1,
        },
        {
          label: this.$t("已完成"),
          number: 0,
          icon: dataSta02,
          value: 2,
        },
        {
          label: this.$t("失败"),
          number: 0,
          icon: dataSta04,
          value: 4,
        },
      ],
    };
  },
  created() {
    // getCurrentUser('header')
    // this.user = storage.get(appConfig.ACCESS_TOKEN_NAME);
    // if (this.user) {
    //   this.login = false;
    // } else {
    //   this.login = true;
    //   // loginOutUser();
    // }
    this.getData();
  },
  computed: {
    ...mapGetters(["getToken"]),
  },
  methods: {
    getData() {
      apiService.post("/user-info").then((res) => {
        const { waitingOrder, doingOrder, doneOrder, refuseOrder } = res.data;
        this.dataStatisticsList[0]["number"] = waitingOrder;
        this.dataStatisticsList[1]["number"] = doingOrder;
        this.dataStatisticsList[2]["number"] = doneOrder;
        this.dataStatisticsList[3]["number"] = refuseOrder;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.data-statistics {
  background-color: #fff;

  .list {
    padding-top: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .item {
      position: relative;
      width: 220px;

      img {
        width: 100%;
      }

      .text {
        position: absolute;
        z-index: 2;
        color: #fff;
        font-size: 14px;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        padding-left: 30px;

        .t2 {
          font-size: 18px;
          font-weight: bold;
          margin-top: 10px;
        }
      }
    }
  }
}
</style>
